
// 动态加载官网的“媒体报道”、“通知公告”内容
function loadnbody(index){
    var bodyContent = "";//新闻列表全部内容（置顶新闻和其他新闻）

    var nbodydiv = $("#nbody"+index);
    var loadnbodyUrl = "/webnews/loadnbody/"+index;

    // 2:媒体报道
    if (index == 2){
        $.ajax({
            url: loadnbodyUrl,
            type: "get",
            dataType: "json",
            success: function (data) {
                var map = eval("(" + data + ")");
                var topNews = map['topNews'];
                var datetime = map['datetime'];
                var newsMapList = map['newsMapList'];

                var topContent = "<div class=\"mainNewsBoxTop\">\n";
                if (topNews != null){
                    topContent = topContent + "<a href=\"/webnews/detail/"+ topNews.id +"/"+ topNews.category +"\" target=\"_blank\" >\n" + "<dl>\n" + "<dt><span>\n" ;
                    if (topNews.picture != null && topNews.picture != ''){
                        topContent = topContent + "<img alt=\""+ topNews.title + "\" src=\""+ topNews.picture +"\"/>\n";
                    }else{
                        topContent = topContent + "<img alt=\""+ topNews.title + "\" src=\"/static/images/nophoto.png\"/>\n";
                    }
                    topContent = topContent + "</span></dt>\n" +
                        "                <dd>"+ topNews.title +"</dd>\n" +
                        "                <dd><span>"+ topNews.description +"</span></dd>\n" +
                        "                <dd><span>"+ datetime +"</span></dd>\n" +
                        "              </dl>\n" +
                        "            </a>\n" +
                        "        </div>";
                }

                var listContent = "<div class=\"mainNewsList\">";
                // 加载新的新闻数据到div中
                var length = newsMapList.length;
                for(var i=0;i< length;i++){

                    var dlContent =  " <dl>\n" +
                        "                <dt><a href=\"/webnews/detail/"+ newsMapList[i]['id']+ "/" +  newsMapList[i]['category']+"\">"+ newsMapList[i]['title'] +"</a></dt>\n" +
                        "                <dd><span>"+ newsMapList[i]['dateTime'] +"</span></dd>\n" +
                        "              </dl>\n";
                }
                listContent = listContent + dlContent + "</div>";
                bodyContent = topContent + listContent;

                nbodydiv.html(bodyContent);
            }
        });
    }
    
    if (index == 3){
        $.ajax({
            url: loadnbodyUrl,
            type: "get",
            dataType: "json",
            success: function (data) {
                var map = eval("(" + data + ")");
                var newsMapList = map['newsMapList'];

                var listContent = "<div class=\"mainNewsList\">";
                // 加载新的新闻数据到div中
                var length = newsMapList.length;
                var dlContent =  "";
                for(var i=0;i< length;i++){
                    dlContent = dlContent + "<dl>\n" +
                                    "            <dt><a href=\"/webnews/detail/"+ newsMapList[i]['id']+ "/" + newsMapList[i]['category'] +"\">"+ newsMapList[i]['title'] +"</a></dt>\n" +
                                    "            <dd><span>"+ newsMapList[i]['dateTime'] +"</span></dd>\n" +
                                    "        </dl>";
                }
                listContent = listContent + dlContent + "</div>";

                nbodydiv.html(listContent);
            }
        });
    }


}
